/**
 * 工时相关类型定义
 */

export interface Workload {
  id: string;
  url: string;
  principal_type: 'idea' | 'work_item' | 'test_case';
  principal: {
    id: string;
    url: string;
    identifier: string;
    title: string;
    type: string;
    start_at?: number;
    end_at?: number;
    parent_id?: string;
    properties?: Record<string, any>;
  };
  type: {
    id: string;
    url: string;
    name: string;
  };
  duration: number; // 工时时长（小时）
  review_state: 'pending' | 'approved' | 'rejected';
  description?: string;
  report_at: number; // 登记日期
  report_by: {
    id: string;
    url: string;
    name: string;
    display_name: string;
    avatar?: string;
  };
  created_at: number;
  created_by: {
    id: string;
    url: string;
    name: string;
    display_name: string;
    avatar?: string;
  };
}

export interface WorkloadType {
  id: string;
  name: string;
}

export interface WorkloadQueryParams {
  principal_type?: 'idea' | 'work_item' | 'test_case';
  pilot_id?: string; // 工时主体所在产品、项目或测试库的id
  principal_id?: string; // 工时主体的id
  start_at?: number; // 登记日期查询的起始时间
  end_at?: number; // 登记日期查询的结束时间
  report_by_id?: string; // 登记人的id
  page_index?: number;
  page_size?: number;
  // 表单临时字段
  dateRange?: any;
}

export interface ApiResponse<T> {
  page_size: number;
  page_index: number;
  total: number;
  values: T[];
  message?: string;
}